package com.zenchn.dynamic;

import static com.zenchn.dynamic.TSysFileDynamicSqlSupport.*;
import static org.mybatis.dynamic.sql.SqlBuilder.*;

import com.zenchn.model.TSysFile;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.BasicColumn;
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.insert.render.MultiRowInsertStatementProvider;
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
import org.mybatis.dynamic.sql.update.UpdateModel;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;

@Mapper
public interface TSysFileDynamicMapper {
    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_file")
    BasicColumn[] selectList = BasicColumn.columnList(fileId, createTime, fileName, filePath, ossBucket, fileType, fileSize);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_file")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_file")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_file")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    int insert(InsertStatementProvider<TSysFile> insertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_file")
    @InsertProvider(type=SqlProviderAdapter.class, method="insertMultiple")
    int insertMultiple(MultiRowInsertStatementProvider<TSysFile> multipleInsertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_file")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("TSysFileResult")
    Optional<TSysFile> selectOne(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_file")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="TSysFileResult", value = {
        @Result(column="file_id", property="fileId", jdbcType=JdbcType.CHAR, id=true),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="file_name", property="fileName", jdbcType=JdbcType.VARCHAR),
        @Result(column="file_path", property="filePath", jdbcType=JdbcType.VARCHAR),
        @Result(column="oss_bucket", property="ossBucket", jdbcType=JdbcType.VARCHAR),
        @Result(column="file_type", property="fileType", jdbcType=JdbcType.VARCHAR),
        @Result(column="file_size", property="fileSize", jdbcType=JdbcType.BIGINT)
    })
    List<TSysFile> selectMany(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_file")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_file")
    default long count(CountDSLCompleter completer) {
        return MyBatis3Utils.countFrom(this::count, TSysFile, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_file")
    default int delete(DeleteDSLCompleter completer) {
        return MyBatis3Utils.deleteFrom(this::delete, TSysFile, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_file")
    default int deleteByPrimaryKey(String fileId_) {
        return delete(c -> 
            c.where(fileId, isEqualTo(fileId_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_file")
    default int insert(TSysFile record) {
        return MyBatis3Utils.insert(this::insert, record, TSysFile, c ->
            c.map(fileId).toProperty("fileId")
            .map(createTime).toProperty("createTime")
            .map(fileName).toProperty("fileName")
            .map(filePath).toProperty("filePath")
            .map(ossBucket).toProperty("ossBucket")
            .map(fileType).toProperty("fileType")
            .map(fileSize).toProperty("fileSize")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_file")
    default int insertMultiple(Collection<TSysFile> records) {
        return MyBatis3Utils.insertMultiple(this::insertMultiple, records, TSysFile, c ->
            c.map(fileId).toProperty("fileId")
            .map(createTime).toProperty("createTime")
            .map(fileName).toProperty("fileName")
            .map(filePath).toProperty("filePath")
            .map(ossBucket).toProperty("ossBucket")
            .map(fileType).toProperty("fileType")
            .map(fileSize).toProperty("fileSize")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_file")
    default int insertSelective(TSysFile record) {
        return MyBatis3Utils.insert(this::insert, record, TSysFile, c ->
            c.map(fileId).toPropertyWhenPresent("fileId", record::getFileId)
            .map(createTime).toPropertyWhenPresent("createTime", record::getCreateTime)
            .map(fileName).toPropertyWhenPresent("fileName", record::getFileName)
            .map(filePath).toPropertyWhenPresent("filePath", record::getFilePath)
            .map(ossBucket).toPropertyWhenPresent("ossBucket", record::getOssBucket)
            .map(fileType).toPropertyWhenPresent("fileType", record::getFileType)
            .map(fileSize).toPropertyWhenPresent("fileSize", record::getFileSize)
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_file")
    default Optional<TSysFile> selectOne(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectOne(this::selectOne, selectList, TSysFile, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_file")
    default List<TSysFile> select(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectList(this::selectMany, selectList, TSysFile, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_file")
    default List<TSysFile> selectDistinct(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectDistinct(this::selectMany, selectList, TSysFile, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_file")
    default Optional<TSysFile> selectByPrimaryKey(String fileId_) {
        return selectOne(c ->
            c.where(fileId, isEqualTo(fileId_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_file")
    default int update(UpdateDSLCompleter completer) {
        return MyBatis3Utils.update(this::update, TSysFile, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_file")
    static UpdateDSL<UpdateModel> updateAllColumns(TSysFile record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(fileId).equalTo(record::getFileId)
                .set(createTime).equalTo(record::getCreateTime)
                .set(fileName).equalTo(record::getFileName)
                .set(filePath).equalTo(record::getFilePath)
                .set(ossBucket).equalTo(record::getOssBucket)
                .set(fileType).equalTo(record::getFileType)
                .set(fileSize).equalTo(record::getFileSize);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_file")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(TSysFile record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(fileId).equalToWhenPresent(record::getFileId)
                .set(createTime).equalToWhenPresent(record::getCreateTime)
                .set(fileName).equalToWhenPresent(record::getFileName)
                .set(filePath).equalToWhenPresent(record::getFilePath)
                .set(ossBucket).equalToWhenPresent(record::getOssBucket)
                .set(fileType).equalToWhenPresent(record::getFileType)
                .set(fileSize).equalToWhenPresent(record::getFileSize);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_file")
    default int updateByPrimaryKey(TSysFile record) {
        return update(c ->
            c.set(createTime).equalTo(record::getCreateTime)
            .set(fileName).equalTo(record::getFileName)
            .set(filePath).equalTo(record::getFilePath)
            .set(ossBucket).equalTo(record::getOssBucket)
            .set(fileType).equalTo(record::getFileType)
            .set(fileSize).equalTo(record::getFileSize)
            .where(fileId, isEqualTo(record::getFileId))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_file")
    default int updateByPrimaryKeySelective(TSysFile record) {
        return update(c ->
            c.set(createTime).equalToWhenPresent(record::getCreateTime)
            .set(fileName).equalToWhenPresent(record::getFileName)
            .set(filePath).equalToWhenPresent(record::getFilePath)
            .set(ossBucket).equalToWhenPresent(record::getOssBucket)
            .set(fileType).equalToWhenPresent(record::getFileType)
            .set(fileSize).equalToWhenPresent(record::getFileSize)
            .where(fileId, isEqualTo(record::getFileId))
        );
    }
}